package jp.dodododo.dao.util;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import jp.dodododo.dao.exception.SQLRuntimeException;

/**
 * 
 * @author Satoshi Kimura
 */
public abstract class PreparedStatementUtil extends StatementUtil {

	public static int executeUpdate(PreparedStatement ps) {
		try {
			return ps.executeUpdate();
		} catch (SQLException e) {
			throw new SQLRuntimeException(e);
		}
	}

	public static void addBatch(PreparedStatement ps) {
		try {
			ps.addBatch();
		} catch (SQLException e) {
			throw new SQLRuntimeException(e);
		}
	}

	public static int[] executeBatch(PreparedStatement ps) {
		try {
			return ps.executeBatch();
		} catch (SQLException e) {
			throw new SQLRuntimeException(e);
		}
	}

	public static ResultSet executeQuery(PreparedStatement ps) {
		try {
			return ps.executeQuery();
		} catch (SQLException e) {
			throw new SQLRuntimeException(e);
		}
	}

}
